package com.foreknow.elmboot.controller;

import com.foreknow.elmboot.po.Orders;
import com.foreknow.elmboot.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/OrdersController")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;
    @RequestMapping("/creatOrders")
    public int creatOrders(Orders orders){
        return ordersService.insertOrders(orders);

    }
    @RequestMapping("/getOrdersById")
    public Orders getOrdersById(Integer orderId){
        return ordersService.getOrdersById(orderId);
    }
    @RequestMapping("/updateOrdersState")
    public int updateOrdersState(Integer orderId) {
        return ordersService.updateOrdersState(orderId);
    }

    @RequestMapping("/listById")
    public List<Orders> listById(String userId) {

        return ordersService.listById(userId);
    }
}
